export default {
  namespaced: true,
  state: {
    //当前主题
    theme: "dark",
    size: "small",
    // 主题列表
    themeList: {},
    // 菜单是否折叠
    menuCollapse: false,
    // 历史页签
    multiBar: true,
    multiBarList: [],
    resize: {
      width: document.body.offsetWidth,
      height: document.body.offsetHeight,
      t: null,
    },
  },
  getters: {},
  mutations: {},
  actions: {
    setTheme({ state }, data) {
      if (data) {
        state.theme = data;
      }
      document
        .getElementsByTagName("body")[0]
        .setAttribute("data-theme", state.theme);
    },
    setSize({ state }, data) {
      state.resize = data;
    },
    setThemeList({ state }, data) {
      state.themeList = data;
    },
    setMenuCollapse({ state, dispatch }, data) {
      state.menuCollapse = data;
      dispatch("setResize");
    },
    setResize({ state }) {
      state.resize = {
        width: document.body.offsetWidth,
        height: document.body.offsetHeight,
        t: new Date().getTime(),
      };
    },
    // 初始化设置
    setSetting({ dispatch }) {
      dispatch("setTheme");
    },
    // 设置是否显示历史页签
    setMultiBar({ state }, bool) {
      state.multiBar = bool;
    },
    // 设置历史页签数据
    setMultiBarList({ state }, arr) {
      state.multiBarList = arr;
    },
    logout({ dispatch }) {
      dispatch("setMultiBarList", []);
    },
  },
};
